import { getPickingOrder } from '@/api/picking-order'
import Pagination from '@/components/Pagination/index'


export default {
  name: 'Packing-Order-Storage',
  components: { Pagination },

  data(){
    return{
      listLoading: true,
      dto: null,
      list: null
    }
  },

  activated(){
    this.init();
  },

  created(){
    //this.getData()
  },

  methods:{

    init(){
      const id = this.$route.query.id
      getPickingOrder(id).then(response => {
        this.dto = response.picking_order
        this.list = this.dto.orders
        this.listLoading = false

        var b = ""
        var _this = this
        document.onkeydown = function() {
          if (event.keyCode != 13) {
            var bizCode = String.fromCharCode(event.keyCode);
            if (event.keyCode >= 48 && event.keyCode <= 122) {
              b = b + bizCode
            }
          } else {
            let f = false
            _this.list.forEach(itm => {
              if(itm.id == b){
                f = true
                _this.$router.push({
                  path: '../picking-item-list/index',
                  query:{
                    order_id: b,
                    id: _this.dto.id
                  }
                })
              }
            })
            if(!f){
              console.log(b)
              _this.$message.error('单号不存在拣货列表')
              b = ""
            }
          }
        }

      }).catch(error => {
        this.dto = null
          this.listLoading = false
      })
    },

    check(id){
      this.$router.push({
        path: '../picking-item-list/index',
        query:{
          order_id: id,
          id: this.dto.id
        }
      })
    }

  }
}
